﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using nSL.Config;

namespace nSL.Libs
{
    public class cString
    {
        public static string ID(string idName)
        {
            XmlDocument Xml = new XmlDocument();

            string lang = Common.CURRENT_LANGUAGE.ToString();
            //string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            //string file = appPath + "\\language\\" + lang + ".xml";
            if (lang == "Eng")
            {
                Xml.LoadXml(AppLanguage.Eng);
            }
            if (lang == "Tha")
            {
                Xml.LoadXml(AppLanguage.Tha);
            }
            string selectNode = String.Format(@"//strings/string[@id='{0}']", idName);
            XmlNode node = Xml.SelectSingleNode(selectNode);
            string idValue = node.Attributes["value"].Value.Trim();

            Xml.RemoveAll();
            Xml = null;
            GC.Collect();

            return idValue;
        }
    }
}
